﻿using Ext.Net.UIS;
using Field = Ext.Net.UIS.Term;
using tag = Ext.Net.UIS.TermTags;


namespace WebPoligon
{
    public class UserUIL
    {
        public static Field NewFields()
        {
            var user = new Entity("User");

            Field.Register(user);

            user.Items.AddRange(
                new Int("ID", tag.ID),
                new Text("FirstName", new TermTitle("First Name", "First")),
                new Text("LastName", new TermTitle("Last Name", "Last")),
                new Union("FullName", tag.Name)
                {
                    Title = "Full Name",
                    ItemNames = "FirstName + ',&nbsp;' + LastName",
                },
                new Text("Email"),
                new Text("UserName"),
                new Text("Password", "Password|(|)"),
                new Bool("IsAdmin", "Is Admin||yesss!!!"),
                new Bool("LoginAllowed", "Login Allowed"),
                new Union("P")
                {
                    Title = "Power",
                    IsNamespace = true,
                    Items = 
                    {
                        new Int("P1", tag.Simple) { Length = 3, },
                        new Label("."),
                        new Int("P2", tag.Simple) { Length = 3, },
                        new Label("."),
                        new Int("P3") { Length = 3, },
                        new Label("."),
                        new Int("P4") { Length = 3, }
                    }
                },
                new Group("FieldSet1", "Term Set 1")
                {
                    ItemNames = "{Composite Name} FirstName + LastName; FullName; ",
                }

            );

            return user;
        }
    }
}